﻿load_assembly 'IronRuby.Libraries', 'IronRuby.StandardLibrary.Zlib'

module RPG
end
class Color
  def self._load(obj)
  end
end
class Table
  def self._load(obj)
  end
end
class Rect
  def self._load(obj)
  end
end
class Tone
  def self._load(obj)
  end
end

class RPG::Tileset
  attr_accessor :id
  attr_accessor :mode
  attr_accessor :name
  attr_accessor :tileset_names
  attr_accessor :flags
  attr_accessor :note
end

class RPG::MapInfo
  attr_accessor :name
  attr_accessor :parent_id
  attr_accessor :order
  attr_accessor :expanded
  attr_accessor :scroll_x
  attr_accessor :scroll_y
end

class RPG::BaseItem
  attr_accessor :id
  attr_accessor :name
  attr_accessor :icon_index
  attr_accessor :description
  attr_accessor :features
  attr_accessor :note
  class Feature
	attr_accessor :code
	attr_accessor :data_id
	attr_accessor :value
  end
end

class RPG::UsableItem < RPG::BaseItem
  attr_accessor :scope
  attr_accessor :occasion
  attr_accessor :speed
  attr_accessor :animation_id
  attr_accessor :success_rate
  attr_accessor :repeats
  attr_accessor :tp_gain
  attr_accessor :hit_type
  attr_accessor :damage
  attr_accessor :effects
  class Damage
	attr_accessor :type
	attr_accessor :element_id
	attr_accessor :formula
	attr_accessor :variance
	attr_accessor :critical
  end
  class Effect
	attr_accessor :code
	attr_accessor :data_id
	attr_accessor :value1
	attr_accessor :value2
  end
end


class RPG::Actor < RPG::BaseItem
  def initialize
	super
	@nickname = ''
	@class_id = 1
	@initial_level = 1
	@max_level = 99
	@character_name = ''
	@character_index = 0
	@face_name = ''
	@face_index = 0
	@equips = [0,0,0,0,0]
  end
  attr_accessor :nickname
  attr_accessor :class_id
  attr_accessor :initial_level
  attr_accessor :max_level
  attr_accessor :character_name
  attr_accessor :character_index
  attr_accessor :face_name
  attr_accessor :face_index
  attr_accessor :equips
end

class RPG::Class < RPG::BaseItem
	def initialize
		super
		@exp_params = [30,20,30,30]
		@params = Table.new(8,100)
		(1..99).each do |i|
		  @params[0,i] = 400+i*50
		  @params[1,i] = 80+i*10
		  (2..5).each {|j| @params[j,i] = 15+i*5/4 }
		  (6..7).each {|j| @params[j,i] = 30+i*5/2 }
		end
		@learnings = []
		@features.push(RPG::BaseItem::Feature.new(23, 0, 1))
		@features.push(RPG::BaseItem::Feature.new(22, 0, 0.95))
		@features.push(RPG::BaseItem::Feature.new(22, 1, 0.05))
		@features.push(RPG::BaseItem::Feature.new(22, 2, 0.04))
		@features.push(RPG::BaseItem::Feature.new(41, 1))
		@features.push(RPG::BaseItem::Feature.new(51, 1))
		@features.push(RPG::BaseItem::Feature.new(52, 1))
	end
	  def exp_for_level(level)
		lv = level.to_f
		basis = @exp_params[0].to_f
		extra = @exp_params[1].to_f
		acc_a = @exp_params[2].to_f
		acc_b = @exp_params[3].to_f
		return (basis*((lv-1)**(0.9+acc_a/250))*lv*(lv+1)/(6+lv**2/50/acc_b)+(lv-1)*extra).round.to_i
	  end
	  attr_accessor :exp_params
	  attr_accessor :params
	  attr_accessor :learnings
	  class Learning
		def initialize
			@level = 1
			@skill_id = 1
			@note = ''
		end
		attr_accessor :level
		attr_accessor :skill_id
		attr_accessor :note
	  end
end

class RPG::Skill < RPG::UsableItem
  attr_accessor :stype_id
  attr_accessor :mp_cost
  attr_accessor :tp_cost
  attr_accessor :message1
  attr_accessor :message2
  attr_accessor :required_wtype_id1
  attr_accessor :required_wtype_id2
end

class RPG::Item < RPG::UsableItem
  attr_accessor :itype_id
  attr_accessor :price
  attr_accessor :consumable
end

class RPG::EquipItem < RPG::BaseItem
  attr_accessor :price
  attr_accessor :etype_id
  attr_accessor :params
end

class RPG::Weapon < RPG::EquipItem
  attr_accessor :wtype_id
  attr_accessor :animation_id
end

class RPG::Armor < RPG::EquipItem
  attr_accessor :atype_id
end

class RPG::Enemy < RPG::BaseItem
  attr_accessor :battler_name
  attr_accessor :battler_hue
  attr_accessor :params
  attr_accessor :exp
  attr_accessor :gold
  attr_accessor :drop_items
  attr_accessor :actions
  class Action
	attr_accessor :skill_id
	attr_accessor :condition_type
	attr_accessor :condition_param1
	attr_accessor :condition_param2
	attr_accessor :rating
  end
  class DropItem
	attr_accessor :kind
	attr_accessor :data_id
	attr_accessor :denominator
  end
end

class RPG::Troop
  attr_accessor :id
  attr_accessor :name
  attr_accessor :members
  attr_accessor :pages
  class Member
	attr_accessor :enemy_id
	attr_accessor :x
	attr_accessor :y
	attr_accessor :hidden
  end
  class Page
	attr_accessor :condition
	attr_accessor :span
	attr_accessor :list
	class Condition
	  attr_accessor :turn_ending
	  attr_accessor :turn_valid
	  attr_accessor :enemy_valid
	  attr_accessor :actor_valid
	  attr_accessor :switch_valid
	  attr_accessor :turn_a
	  attr_accessor :turn_b
	  attr_accessor :enemy_index
	  attr_accessor :enemy_hp
	  attr_accessor :actor_id
	  attr_accessor :actor_hp
	  attr_accessor :switch_id
	end
  end
end

class RPG::State < RPG::BaseItem
  attr_accessor :restriction
  attr_accessor :priority
  attr_accessor :remove_at_battle_end
  attr_accessor :remove_by_restriction
  attr_accessor :auto_removal_timing
  attr_accessor :min_turns
  attr_accessor :max_turns
  attr_accessor :remove_by_damage
  attr_accessor :chance_by_damage
  attr_accessor :remove_by_walking
  attr_accessor :steps_to_remove
  attr_accessor :message1
  attr_accessor :message2
  attr_accessor :message3
  attr_accessor :message4
end

class RPG::Animation
  attr_accessor :id
  attr_accessor :name
  attr_accessor :animation1_name
  attr_accessor :animation1_hue
  attr_accessor :animation2_name
  attr_accessor :animation2_hue
  attr_accessor :position
  attr_accessor :frame_max
  attr_accessor :frames
  attr_accessor :timings
  class Frame
	attr_accessor :cell_max
	attr_accessor :cell_data
  end
  class Timing
	attr_accessor :frame
	attr_accessor :se
	attr_accessor :flash_scope
	attr_accessor :flash_color
	attr_accessor :flash_duration
  end
end

class RPG::CommonEvent
  attr_accessor :id
  attr_accessor :name
  attr_accessor :trigger
  attr_accessor :switch_id
  attr_accessor :list
end

class RPG::EventCommand
  attr_accessor :code
  attr_accessor :indent
  attr_accessor :parameters
end

class RPG::System
  attr_accessor :game_title
  attr_accessor :version_id
  attr_accessor :japanese
  attr_accessor :party_members
  attr_accessor :currency_unit
  attr_accessor :skill_types
  attr_accessor :weapon_types
  attr_accessor :armor_types
  attr_accessor :elements
  attr_accessor :switches
  attr_accessor :variables
  attr_accessor :boat
  attr_accessor :ship
  attr_accessor :airship
  attr_accessor :title1_name
  attr_accessor :title2_name
  attr_accessor :opt_draw_title
  attr_accessor :opt_use_midi
  attr_accessor :opt_transparent
  attr_accessor :opt_followers
  attr_accessor :opt_slip_death
  attr_accessor :opt_floor_death
  attr_accessor :opt_display_tp
  attr_accessor :opt_extra_exp
  attr_accessor :window_tone
  attr_accessor :title_bgm
  attr_accessor :battle_bgm
  attr_accessor :battle_end_me
  attr_accessor :gameover_me
  attr_accessor :sounds
  attr_accessor :test_battlers
  attr_accessor :test_troop_id
  attr_accessor :start_map_id
  attr_accessor :start_x
  attr_accessor :start_y
  attr_accessor :terms
  attr_accessor :battleback1_name
  attr_accessor :battleback2_name
  attr_accessor :battler_name
  attr_accessor :battler_hue
  attr_accessor :edit_map_id
  class Terms
	attr_accessor :basic
	attr_accessor :params
	attr_accessor :etypes
	attr_accessor :commands
  end
  class TestBattler
	attr_accessor :actor_id
	attr_accessor :level
	attr_accessor :equips
  end
  class Vehicle
	attr_accessor :character_name
	attr_accessor :character_index
	attr_accessor :bgm
	attr_accessor :start_map_id
	attr_accessor :start_x
	attr_accessor :start_y
  end
end

class RPG::AudioFile
  attr_accessor :name
  attr_accessor :volume
  attr_accessor :pitch
end

class RPG::BGM < RPG::AudioFile
  attr_accessor :pos
end

class RPG::BGS < RPG::AudioFile
  attr_accessor :pos
end

class RPG::ME < RPG::AudioFile
end

class RPG::SE < RPG::AudioFile
end



class RPG::Event
  attr_accessor :id
  attr_accessor :name
  attr_accessor :x
  attr_accessor :y
  attr_accessor :pages
  class Page
	attr_accessor :condition
	attr_accessor :graphic
	attr_accessor :move_type
	attr_accessor :move_speed
	attr_accessor :move_frequency
	attr_accessor :move_route
	attr_accessor :walk_anime
	attr_accessor :step_anime
	attr_accessor :direction_fix
	attr_accessor :through
	attr_accessor :priority_type
	attr_accessor :trigger
	attr_accessor :list
	class Condition
	  attr_accessor :switch1_valid
	  attr_accessor :switch2_valid
	  attr_accessor :variable_valid
	  attr_accessor :self_switch_valid
	  attr_accessor :item_valid
	  attr_accessor :actor_valid
	  attr_accessor :switch1_id
	  attr_accessor :switch2_id
	  attr_accessor :variable_id
	  attr_accessor :variable_value
	  attr_accessor :self_switch_ch
	  attr_accessor :item_id
	  attr_accessor :actor_id
	end
	class Graphic
	  attr_accessor :tile_id
	  attr_accessor :character_name
	  attr_accessor :character_index
	  attr_accessor :direction
	  attr_accessor :pattern
	end
  end
end

class RPG::Map
  attr_accessor :display_name
  attr_accessor :tileset_id
  attr_accessor :width
  attr_accessor :height
  attr_accessor :scroll_type
  attr_accessor :specify_battleback
  attr_accessor :battleback1_name
  attr_accessor :battleback2_name
  attr_accessor :autoplay_bgm
  attr_accessor :bgm
  attr_accessor :autoplay_bgs
  attr_accessor :bgs
  attr_accessor :disable_dashing
  attr_accessor :encounter_list
  attr_accessor :encounter_step
  attr_accessor :parallax_name
  attr_accessor :parallax_loop_x
  attr_accessor :parallax_loop_y
  attr_accessor :parallax_sx
  attr_accessor :parallax_sy
  attr_accessor :parallax_show
  attr_accessor :note
  attr_accessor :data
  attr_accessor :events
  class RPG::Map::Encounter
	attr_accessor :troop_id
	attr_accessor :weight
	attr_accessor :region_set
  end
end

class RPG::MoveRoute
  attr_accessor :repeat
  attr_accessor :skippable
  attr_accessor :wait
  attr_accessor :list
end

class RPG::MoveCommand
  attr_accessor :code
  attr_accessor :parameters
end


class PDQ
  def initialize()
  end

  def load(fname)
	fp = File.open(fname, 'rb') 
	code = fp.read
	src = Marshal.load(code)
	fp.close()
	src
  end
end

